LotusScript Doc

LotusScript library: LSALibOCIMgr

Options
Declare
Public

Global variables
Private InstanceS List = Variant
Public InstanceSUbound = Integer
Public ContextDoc = NotesDocument
Public InstanceName = String

The motivation for this module is, to be able to use instances defined in a subfrom within a form Context or vice versa. This is usually impossible because the scope of the global variables is restricted to either a form or a subform.
The instance manager is a central place to register instances of a class and to retrieve them from any place. You may
For example:
Assume you have the following code in the form
Dim MyHandle as String
Dim MyInstance as MyClass
Set MyInstance = New MyClass(...)
MyHandle = ICheckInHandle(MyInstance , "MyUniqueSuggestedID")
MyInstance.AttribX
:
in the subform you can refere to it
Dim MyLocalInstance as New MyClass
Set MyLocalInstance = Irefer( "MyUniqueSuggestedID", Nothing)
' continue your code as if the instance would be owned by the subform form.
MyLocalInstance.AttribX
:
Usually the destructor of a class 'delete' will call
ICheckout Me

As OCIMgr is designed to work together with classes generated by the "OCards", a tool for specification of objects and code generation, the "IcheckInOC" assumes the instance to carry the current Notes Document in the class variable "ContextDoc" as well as the suggested ID in "ContextInstanceId".
If your class is does not follow this conventions, you have to use the "IcheckInOCHandle" method.
An Internal handle allways makes sure that there is a unique key by adding a time stamp with accuracy of a second and within that a random number of 3 digits to the suggested ID.
OCIMgr is a base functionality that needs no prerequisites nor configuration.

Author:
LPS EMEA
Version:
2.0.0 24.MAR.2000
History:
24.MAR.2000EScextracted functionality from the former Imgr
24.MAR.2000EScadded a general Functionality ICheckInOC and IcheckInHandle for Ocard instances and arbitrary objects.
02.MAY.2000EScAdded robust handling for IRefer in case of invalid references to instances
08.JUN.2000EScAllow handle as parameter to ICheckOut and randomize handle below subsecond level


Method Summary
Function CodeDateTime (ProcessDate As Variant) As String
Sub ICheckIn (Instance As Variant)
Function ICheckInHandle (instance As Variant, suggestedID As String) As String
Sub ICheckInOC (Instance As Variant)
Sub ICheckOut (Instance As Variant)
Function IRefer (Handle As String, Context As Variant) As Variant
Sub IRename (Instance As Variant, InstanceId As String)

Method Detail

ICheckInOC

Public Sub ICheckInOC(Instance As Variant)
Checks in an instance into the instance manager with the suggested ID automaticly created This functionality is specific for instances of classes generated by Ocard, in that we make use of the fact that it carries the member variables "Context Doc" and the "Context InstanceId" in the instance .

Parameters:
InstanceVariantany ocard generated instance
Summmary Top

ICheckOut

Public Sub ICheckOut(Instance As Variant)
Remove the Instance from the List as maitained by the instance manager ICheckOut must be caled called in the destructor of a class.

HINT:
If you ommit the checkout, you risk kind of memory leeks, as the instances are preserved until the program comes too a final end. Even system hang ups ( loops ) have been reported
Example:
call ICheckOut(Me)

Dim Handle as String
handle = IcheckInHandle( Myinstance, Myid)
:
call ICheckOut(Me)


Parameters:
InstanceVariantany instance or handle to the instance
Summmary Top

IRename

Public Sub IRename(Instance As Variant,InstanceId As String)

History:
24.MAR.2000EScFunction removed as it is nolonger used
Summmary Top

IRefer

Public Function IRefer(Handle As String,Context As Variant) As Variant
Retrieves the object that is checked in corresponding to the handle. You may call with an incomplete handle if you give a context in which the object lives and which has a creation date as a further qualifier. This context can be a NotesDocument, NotesUIDocument or any class generated by Object cards which document it belongs to. If the instance is not found irefer returns "nothing".

Parameters:
InstanceIDStringthe ID of the instance to be retrieved
ContextVariantthat allows to find a NotesDocument context
Returns:
Variantobject of class x as stored before
History:
02.MAY.2000EScAdded error handling in case of invalid references to instances, they yust passed into the seach loop but instanceId is only available for OC classes.
Summmary Top

ICheckInHandle

Public Function ICheckInHandle(instance As Variant,suggestedID As String) As String
Checks in the instance into the instance manager. A handle is returned which is the prefered way to access the Instance via IRefer or ICheckout. with the suggested ID. If no ID is suggested ("") a random ID is generated.
Example:
MyHandle = ICheckInHandle(Me,"AddrMgr") returns "ADDRMGR#24-12-1999 14:30:59.969" where 969 is a random number

Parameters:
instanceVariantObject of any class
suggestedIDStringsuggestion for the ID
Returns:
StringID by which object can be accessed
See also:
LSALibOCImgr#IRefer
LSALibOCImgr#ICheckOut
Summmary Top

CodeDateTime

Private Function CodeDateTime(ProcessDate As Variant) As String
converts a date into an UDF compliant textual representation like
24-03-2000 15:32:20
If the format is invalid, it returns
00-00-0000 00:00:00

This function is the same as VCodeDateTime but kept here to make this module independent.

Parameters:
ProcessDateVariantof type date
Returns:
Stringthe converted textual date/ time representation
See also:
LSALibFct#VCodeDateTime
Summmary Top

ICheckIn

Public Sub ICheckIn(Instance As Variant)
Old function kept for upward compatibility

See also:
LSALibOCImgr.#ICheckInOC
Summmary Top

TopLotusScript Doc
© Lotus Professional Services
generated on : 05-Apr-01 10:01:44 AM